package sixyz.service;


import sixyz.entity.Book;
import sixyz.dao.BookDAO;

import java.sql.SQLException;
import java.util.ArrayList;

public class BookService {

    private final BookDAO bookDAO = BookDAO.getInstance();

    public void addNewBook(String name, String author, String description) throws SQLException, ClassNotFoundException, IllegalAccessException {
        Book book = new Book(name, author, description);
        bookDAO.insertABook(book);
    }

    public ArrayList<Book> listAllBooks() throws SQLException, ClassNotFoundException {
        return bookDAO.queryAllBooks();
    }

    public void deleteBook(Integer id) throws SQLException, ClassNotFoundException {
        bookDAO.deleteBookById(id);
    }
}
